HTMLify
app.js
Views: 16 | Author: huxn-webdev
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | const title = document.getElementById("title"); const author = document.getElementById("author"); const year = document.getElementById("year"); const bookList = document.getElementById("book-list"); const btn = document.querySelector(".btn"); btn.addEventListener("click", function (e) { e.preventDefault(); if (title.value == "" && author.value == "" && year.value == "") { alert("Fill The Form"); } else { const newRow = document.createElement("section"); // Creating new Title const newTitle = document.createElement("div"); newTitle.innerHTML = title.value; newRow.appendChild(newTitle); // Creating new Author const newAuthor = document.createElement("div"); newAuthor.innerHTML = author.value; newRow.append(newAuthor); // Creating new Year const newYear = document.createElement("div"); newYear.innerHTML = year.value; newRow.appendChild(newYear); bookList.appendChild(newRow); } }); |